<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="css/pintuer.css">
    <link rel="stylesheet" href="css/admin.css">
    <script src="js/jquery.js"></script>
    <script src="js/pintuer.js"></script>
    <script src="/js/vuejs-2.5.16.js"></script>
    <script src="/js/axios-0.18.0.js"></script>
	<script src="/js/laydate/laydate.js"></script>
</head>
<body>
<div class="panel admin-panel" id="moviesDiv">
    <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>修改问题</strong></div>
    <div class="body-content">
        <form method="post" class="form-x">
            <input type="hidden" name="id" v-model="questions.id">
            <div class="form-group">
                <div class="label">
                    <label>问题内容：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" v-model="questions.question" name="question"/>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>问题等级：</label>
                </div>
                <div class="field">
                    <select name="level" class="input" style="width:200px; line-height:17px;" v-model="questions.level">
                        <option selected>请选择等级</option>
                        <option>初级</option>
                        <option>中级</option>
                        <option>高级</option>
                    </select>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>选项一：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" v-model="questions.options[0]" name="option1"/>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>选项二：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" v-model="questions.options[1]" name="option2"/>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>选项三：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" v-model="questions.options[2]" name="option3"/>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label>选项四：</label>
                </div>
                <div class="field">
                    <input type="text" class="input w50" v-model="questions.options[3]" name="option4"/>
                    <div class="tips"></div>
                </div>
            </div>

            <div class="form-group">
                <div class="label">
                    <label></label>
                </div>
                <div class="field">
                    <a class="button bg-main icon-check-square-o" @click="saveQuestions()"> 提交</a>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    const app = new Vue({
        el: '#moviesDiv',
        data: {
            questions: {},
            question: "",
            options: []
        },
        methods: {

            selectQuestionById(questionId) {

                axios.get("/soul/question/select/" + questionId).then(resp => {

                    this.questions = resp.data;
                })
            },

            saveQuestions(){


                axios.post("/soul/question/update",this.questions).then(resp =>{

                    if (resp.data){

                        location.href = "soul_list.html";
                    } else {

                        alert("保存失败")
                    }

                })
            }

        },

        created(){

            let questionId = location.search.split("=")[1];

            if (questionId != null) {

                this.selectQuestionById(decodeURI(questionId))
            }
        },
    })
</script>

<script>
    lay('#version').html('-v' + laydate.v);
    //执行一个laydate实例
    laydate.render({
        elem: '#showTime' //指定元素
    });
</script>
<script src="/js/verify.js"></script>
</body>
</html>